#include "qworldview.h"

#include <QGraphicsScene>
#include <QWheelEvent>
#include <QDebug>

QWorldView::QWorldView ( QGraphicsScene *scene ) : QGraphicsView ( scene )
{
	resizeScene = false;
}

QWorldView::~QWorldView()
{}

bool QWorldView::getResizeScene() const
{
	return resizeScene;
}

void QWorldView::setResizeScene ( bool theValue )
{
	resizeScene = theValue;
}

void QWorldView::resizeEvent ( QResizeEvent* )
{
	if ( resizeScene ) scene() -> setSceneRect ( 0, 0, width() - 20, height() - 20 );
}

void QWorldView::wheelEvent ( QWheelEvent* event )
{
	qreal deg = ( qreal ) ( event -> delta() ) / 100;

	if ( deg > 0 ) scale ( deg, deg );
	else if ( deg < 0 ) scale ( -1/deg, -1/deg );
}
